package inventory.service.impl;

import inventory.entity.*;
import inventory.mapper.MaterialCategoryMapper;
import inventory.mapper.MaterialTypicalMapper;
import inventory.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TypeServiceImpl implements TypeService {

    @Autowired
    MaterialCategoryMapper materialCategoryMapper;

    @Autowired
    MaterialTypicalMapper materialTypicalMapper;

    @Override
    public void addMaterialCategory(MaterialCategory materialCategory) {
        materialCategoryMapper.insert(materialCategory);
    }

    @Override
    public void deleteMaterialCategoryById(String categoryId) {
        materialCategoryMapper.deleteByPrimaryKey(categoryId);
    }

    @Transactional
    @Override
    public void modifyMaterialCategoryById(MaterialCategory materialCategory) {
        materialCategoryMapper.updateByPrimaryKeySelective(materialCategory);
    }

    @Override
    public MaterialCategory selectMaterialCategory(String categoryId) {
        return materialCategoryMapper.selectByPrimaryKey(categoryId);
    }

    @Override
    public List queryCity() {
        return materialTypicalMapper.queryAllCity();
    }

    @Override
    public List queryCounty() {
        return materialTypicalMapper.queryAllCounty();
    }

    @Override
    public void addMaterialType(MaterialTypical materialTypical) {
        materialTypicalMapper.insert(materialTypical);
    }

    @Override
    public void deleteMaterialTypeById(String typicalId) {
        materialTypicalMapper.deleteByPrimaryKey(typicalId);
    }

    @Transactional
    @Override
    public void modifyMaterialTypeById(MaterialTypical materialTypical) {
        materialTypicalMapper.updateByPrimaryKeySelective(materialTypical);
    }

    @Override
    public MaterialTypical selectMaterialType(String typicalId) {
        return materialTypicalMapper.selectByPrimaryKey(typicalId);
    }


}
